$(document).ready(function(){
    let $num = $('#num')
    let sourceNode = document.getElementById('info1')

    $("#num").bind("input propertychange",function(){

        for(let i = 1; i < 4; i++){
            let node = document.getElementById("info" + (i+1));
            if(node){
                node.parentNode.removeChild(node);
            }
        }

        for(let i = 0; i < $num.val(); i++){
            if(document.getElementById("info" + (i + 1))){
                continue;
            }
            let cloneNode = sourceNode.cloneNode(true);
            cloneNode.setAttribute("id", "info" + (i+1));
            sourceNode.parentNode.appendChild(cloneNode);
        }

        for(let i = $num.val(); i < 4; i++){
            let node = document.getElementById("info" + (i+1));
            if(node){
                node.parentNode.removeChild(node);
            }
        }

    });
    

});   